/**
  * @Description: WoShop商城
  * @Author: 梧桐
  * @Copyright: 武汉一一零七科技有限公司©版权所有
  * @Link: www.s1107.com
  * @Contact: QQ:2487937004
  */
<template>
  <view >
    <view class="inputWrap">
      <u-input class="input"  v-model="phone" placeholder="请填写联系电话" maxlength="11" :border="true" border-color="#eee" disabled/>
        <view class="u-flex u-row-between u-col-center">
          <u-input class="input"  v-model="code" placeholder="请输入验证码"   maxlength="6" :border="true" border-color="#eee" />
            <text class="sendcoder" @click="editPwdSms"  >{{clickText}}</text>
        </view>
        <u-button type="warning" mode="plain" style="margin-top: 40upx;background-color: #EC4849;" @click="confirmClick">确定</u-button>
   
    </view>
  </view>
</template>

<script>
let courr = 60;
let setId = null;
export default {
 
  data() {
    return {
      phone: "",
      newpwd: "",
      newpwd2: "",
      code: "",
      clickText: ""
    };
  },
  onLoad() {
    this.gethuoquphone();
    uni.setNavigationBarTitle({
      title: '验证身份'
    });
    this.clickText = '获取验证码'
  },
  copmputed:{
    returnPwd(){
      return this.newpwd===this.newpwd2
    }
  },

  methods: {
    confirmClick() {
		this.$http.xaohao({code: this.code }).then(res => {
			console.log(res,"6666")
			if (res.status == 200) {
				uni.showToast({
					title:'注销成功'
				})
			 setTimeout(()=>{
				 uni.navigateTo({
				 	url:'/pagesB/login/login'
				 })
			 },1000)
			}
		});
    },
    editPwdSms() {
      if (this.phone.length != 11) {
        this.$toast('请输入正确的手机号');
        return false;
      }
      if (setId) {
        // 禁止重复发送
        return false;
      }
      this.$http.editPwdSms({ phone: this.phone }).then(res => {
        if (res.status == 200) {
          this.$toast(res.mess);
          setId = setInterval(() => {
            courr--;
            if (courr == 0) {
              courr = 60;
              clearInterval(setId);
              this.clickText = '重新获取';

              return false;
            }
            this.clickText = courr + "s";
          }, 1000);
        }
      });
    },
    gethuoquphone() {
      this.$http.gethuoquphone().then(res => {
        if (res.status == 200) {
          this.phone = res.data.phone;
        }else{
			uni.showToast({
				title:'请先绑定手机号'
			})
		}
      });
    }
  }
};
</script>

<style scoped>
.inputWrap{
  
  background-color: #fff;
  padding: 30upx;
}
.input{
  height:80upx;
  margin: 20upx 0;
}
.sendcoder{
  font-size: 24upx;
  color: #ffa468;
  margin-left: 20upx;
}
</style>
